import React from 'react';

class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            message: "hello world",
            currentIndex: 0
        }
        this.increment = this.increment.bind(this)
        this.changeMes = this.changeMes.bind(this)

    }

    increment() {
        this.setState((state, props) => {
            console.log(state.message,state.currentIndex+1, props.message)
        })
    }


    changeMes() {
        this.setState({
            message: 'Hello react'
        }, () => {
            console.log("26", this.state.message)
        })
        console.log("28", this.state.message)
    }

    render() {
        return (
            <div>
                <h2>{this.state.message}</h2>
                <h2>{this.state.currentIndex}</h2>
                <button onClick={this.changeMes}>change</button>
                <button onClick={this.increment}>+1</button>
            </div>
        );
    }
}

export default App;